package com.hc.base;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class ResultVo<T> {

    private Integer code;  //状态码
    private String message;  //返回信息
    private T data;    //返回数据

    private ResultVo(){}

    public static <T> ResultVo<T> ok(){
        ResultVo<T> result = new ResultVo<>();
        result.setCode(ResultEnum.OK.getCode());
        result.setMessage(ResultEnum.OK.getMessage());
        return  result;
    }


    public static <T> ResultVo<T> ok(T data){
        ResultVo<T> result = new ResultVo<>();
        result.setCode(ResultEnum.OK.getCode());
        result.setMessage(ResultEnum.OK.getMessage());
        result.setData(data);
        return  result;
    }

    public static <T> ResultVo<T> error(){
        ResultVo<T> result = new ResultVo<>();
        result.setCode(ResultEnum.FAIL.getCode());
        result.setMessage(ResultEnum.FAIL.getMessage());
        return  result;
    }

    public static <T> ResultVo<T> build(){
        ResultVo<T> result = new ResultVo<>();
        return  result;
    }

    public ResultVo<T> code(Integer code){
        this.setCode(code);
        return  this;
    }

    public ResultVo<T> message(String message){
        this.setMessage(message);
        return  this;
    }

    public ResultVo<T> data(T data){
        this.setData(data);
        return  this;
    }




}
